#include <inc/types.h>

struct rsdp
{
	uint8_t sig[8];
	uint8_t check_sum;
	uint8_t oemid[6];
	uint8_t revision;
	uint32_t rsdt_addr;
	uint32_t length;
	uint64_t xsdt_addr;
	uint8_t exted_check;
	uint8_t resverd[3];
}__attribute__((packed));

struct des_header
{
	uint8_t sig[4];
	uint32_t length;
	uint8_t revision;
	uint8_t check_sum;
	uint8_t oemid[6];
	uint8_t oemtabid[8];
	uint32_t oem_revision;
	uint32_t creator_id;
	uint32_t creator_revision;
}__attribute__((packed));

struct xsdt
{
	struct des_header header;
	uint64_t entry[];
}__attribute__((packed));

struct srat
{
	struct des_header header;
	uint32_t reserved;
	uint64_t reserved1;
	uint64_t entry[];
}__attribute__((packed));

struct ivrs
{
	struct des_header header;
	uint32_t ivinfo;
	uint32_t reserved1;
	uint64_t entry[];
}__attribute__((packed));

struct apic_aff
{
	uint8_t type; 					//type = 0
	uint8_t length; 				//16 bytes
	uint8_t proxi_domain;
	uint8_t apic_id;
	uint32_t flags; 			 	//bit 0 enabled/disabled, 0-31 MBZ
	uint8_t lsapic_eid;
	uint8_t proxi_domain1[3];
	uint32_t resv;
}__attribute__((packed));

struct mem_aff
{
	uint8_t type; 					//type = 1
	uint8_t length; 				//40 bytes
	uint32_t proxi_domain;
	uint16_t resv;
	uint32_t base_addr_low;
	uint32_t base_addr_high;
	uint32_t length_low;
	uint32_t length_high;
	uint32_t resv1;
	uint32_t flags; 				//bit 0 enabled/disabled, 1 hot plug, 2 non volatile,MBZ
	uint64_t resv2;
}__attribute__((packed));


struct numa_node
{
	uint64_t id;
	uint8_t lapicid[8];
	uint64_t base_addr;
	uint64_t length;
	uint64_t index;
}__attribute__((packed));

struct rsdp *rsdp_get(void);
struct srat *srat_get(struct xsdt *xt);
struct ivrs *ivrs_get(struct xsdt *xt);
int srat_parse(struct srat *srat);

